package com.designPatterns.proxy;

/**
 * Created by houjinxin on 16/3/29.
 */
public class Target3 implements ITarget3 {

    private ITarget3 proxy;

    public Target3() {}

    @Override
    public void say(String word) {
        if (isProxyExist()) {
            System.out.println(word);
        } else {
            System.out.println("请使用指定代理访问");
        }
    }

    @Override
    public ITarget3 getProxy() {
        this.proxy = new StaticProxy3(this);
        return proxy;
    }

    private boolean isProxyExist() {
        return this.proxy != null;
    }
}
